/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package multiscreens;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.beans.property.DoubleProperty;
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.util.Duration;

/**
 *
 * @author Ahmed
 */
public class UserInterfaceController implements Initializable {

    @FXML
    private Label label;
    @FXML
    private StackPane stack1;
    @FXML
    private Button button1;

    @FXML
    private void handleButtonAction(ActionEvent event) {
        final DoubleProperty opacity = stack1.opacityProperty();
        
       
                        
        Timeline fade = new Timeline(
                new KeyFrame(Duration.ZERO,
                new KeyValue(opacity, 1.0)),
                new KeyFrame(new Duration(1000),new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent event) {
                 stack1.getChildren().clear();
                stack1.getChildren().add(0, new Button("hello"));
                 Timeline fadein = new Timeline(
                new KeyFrame(Duration.ZERO,
                new KeyValue(opacity, 0.0)),
                new KeyFrame(new Duration(1000)
               ,new KeyValue(opacity,  1.0)));
        fadein.play();
                
            }
        }
               ,new KeyValue(opacity,  0.0)));
        fade.play();
        
       
    }
                 
    
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }
}
